﻿Public Class perRegiao
    Inherits AcessoBd

    Public Sub inserirRegiaoProposta(ByVal iCodRegiao As Int32,
                                     ByVal iCodProposta As Int32,
                                     ByVal iRevProposta As Int32,
                                     ByVal sDescricao As String,
                                     ByVal sComentario As String)
        Dim sSql As String

        sSql = "INSERT INTO proposta_regiao" & Environment.NewLine &
               "           (codRegiao" & Environment.NewLine &
               "           ,codProposta" & Environment.NewLine &
               "           ,revProposta" & Environment.NewLine &
               "           ,descricao" & Environment.NewLine &
               "           ,comentario)" & Environment.NewLine &
               "        VALUES" & Environment.NewLine &
               "           (@CodRegiao" & Environment.NewLine &
               "           ,@codProposta" & Environment.NewLine &
               "           ,@revProposta" & Environment.NewLine &
               "           ,@descricao" & Environment.NewLine &
               "           ,@comentario)"

        With MyBase.SQLCmd.Parameters
            .Clear()
            .AddWithValue("@codRegiao", iCodRegiao)
            .AddWithValue("@codProposta", iCodProposta)
            .AddWithValue("@revProposta", iRevProposta)
            .AddWithValue("@descricao", sDescricao)
            .AddWithValue("@comentario", sComentario)
        End With

        MyBase.executarAcao(sSql)

    End Sub

    Public Function retornarRegiaoProposta(ByVal iCodProposta As Int32, ByVal iRevisao As Int32) As DataTable
        Dim sSql As String

        sSql = "SELECT CodRegiao, descricao as Regiao" & Environment.NewLine &
               "  FROM proposta_regiao " & Environment.NewLine &
               " WHERE codProposta = @codProposta " & Environment.NewLine &
               "   AND revProposta = @revProposta " & Environment.NewLine &
               " ORDER BY codRegiao"

        With MyBase.SQLCmd.Parameters
            .Clear()
            .AddWithValue("codProposta", iCodProposta)
            .AddWithValue("revProposta", iRevisao)
        End With

        Return MyBase.executarConsulta(sSql)

    End Function

End Class
